package events.edit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import snazzysprites.SnazzySprites;
import shapes.SnazzyShape;
import state.SnazzySpritesStateManager;

/**
 * This handler moves the selected shape to the back of the pose
 * @author Andrew
 */
public class MoveToBackHandler implements ActionListener
{
    /**
     * This method relays this event to the state manager, which
     * will update the clipboard accordingly.
     * 
     * @param ae The event object for this button press.
     */
    @Override
    public void actionPerformed(ActionEvent ae) 
    {
        SnazzySprites singleton = SnazzySprites.getSnazzySprites();
        SnazzySpritesStateManager poseurStateManager = singleton.getStateManager();
        LinkedList<SnazzyShape> list = poseurStateManager.getPose().getShapesList();
        SnazzyShape shape = poseurStateManager.getSelectedShape();
        list.remove(shape);
        list.addFirst(shape);
        poseurStateManager.refreshState();
    }   
}
